package ru.myrtle.umf.query.condition.object;

import ru.myrtle.umf.UAttribute;
import ru.myrtle.umf.UObject;
import ru.myrtle.umf.query.UCondition;

public class UObjectAttributeValueCondition extends UObjectCondition {

    private final UAttribute attribute;
    private final UCondition condition;

    public UObjectAttributeValueCondition(UAttribute attribute, UCondition condition) {
        this.attribute = attribute;
        this.condition = condition;
    }

    @Override
    protected boolean isSatisfiedImpl(UObject object) {
        Object value = attribute.getValue(object);

        return condition.isSatisfied(
                value
        );
    }
}
